package homeactivity.pingpaiadapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yztc.thinkpad.mandemo.R;

import java.util.List;

import homeactivity.bean.PingpaiContentBean;
import utils.OnItemClickListener;

/**
 * Created by Administrator on 2016/10/11.
 */
public class GrideAdapter extends RecyclerView.Adapter<GrideAdapter.MyViewHolder> {
    private Context context;
    private List<PingpaiContentBean.DataBean> list;
//    private OnItemClickListener listener;
//    public void setListener(OnItemClickListener listener) {
//        this.listener = listener;
//    }
    public  GrideAdapter(Context context,List<PingpaiContentBean.DataBean> list){
        this.context=context;
        this.list=list;
    }
    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder=new MyViewHolder(LayoutInflater.from(context).
                inflate(R.layout.pingpaicontent_item,parent,false));
        return holder;
    }
    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.title.setText(list.get(position).getTitle());
        holder.price.setText(list.get(position).getCoupon_price());
        Glide.with(context).load(list.get(position).getPic_url()).into(holder.imageView);
    }
    @Override
    public int getItemCount() {
        return list.size();
    }
    class  MyViewHolder extends RecyclerView.ViewHolder {
        TextView price,title;
        ImageView imageView;
        public MyViewHolder(View itemView) {
            super(itemView);
            price= (TextView) itemView.findViewById(R.id.pingpai_gv_price);
            title= (TextView) itemView.findViewById(R.id.pingpai_gv_title);
            imageView= (ImageView) itemView.findViewById(R.id.pingpai_gv_iv);
        }
    }
}
